package org.example.extend.cmp3;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @author xiajiqiu
 * @since 2024/6/8 21:40
 */
@Slf4j
public class CustomBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        // 初始化之前执行
        log.info("custom postProcessBeforeInitialization execute beanName:{} bean:{}", beanName, bean);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        // 初始化之后执行
        log.info("custom postProcessAfterInitialization execute beanName:{} bean:{}", beanName, bean);
        return bean;
    }
}
